<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<%@ page import="java.sql.*" %>
<!DOCTYPE html>
<html>
<%

    String url = "jdbc:mysql://localhost:3306/carxianyu";
    String user = "root";
    String pwd = "root";



    String sql = "select * from liuyan ORDER BY createtime desc ";

    //jdbc 连接数据库
    Class.forName("com.mysql.jdbc.Driver");//加载驱动
    Connection conn = DriverManager.getConnection("jdbc:mysql://43.142.239.28:13307/carxianyu?useUnicode=true&characterEncoding=UTF-8&serverTimeZone=UTC","root","root");
    PreparedStatement a = conn.prepareStatement(sql);
    ResultSet rs = a.executeQuery();
    System.out.println("执行了sql =====》"+sql);
%>

<head>
    <meta charset="utf-8">
    <title>二手汽车平台——留言板</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/static/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${ctx}/static/layui/style/admin.css" media="all">
    <link rel="stylesheet" href="${ctx}/static/layui/style/template.css" media="all">
    <script src="${ctx}/static/layui/layui.js"></script>
</head>
<body>
<!--导航条 start-->
<jsp:include page="/head.jsp"/>

<!--导航条 end-->

<!--轮播图 start-->
<jsp:include page="/banner.jsp"/>
<!--轮播图 end-->


<div class="layui-container layadmin-cmdlist-fluid">


<!--liuyan列表-->

    <div class="layui-row layui-col-space30" style="margin-top: 50px;">




        <div class="layui-collapse">





                        <form class="layui-form layui-form-pane" action="${ctx}/view/back/liuyan/doLiuyyanExcute.jsp?" method="post">
                            <div class="layui-form-item layui-form-text">
                                <label class="layui-form-label" id="commentShow">信息显示</label>
                                <div class="layui-input-block">
                                    <textarea name="message" placeholder="请输入留言内容" class="layui-textarea"></textarea>
                                    <div hidden>
                                        <input type="text" name="state" value="1">
                                    </div>
                                </div>
                            </div>


                            <c:if test="${sessionScope.depart !=22}">
                                <span class="layui-btn layui-btn-fluid layui-btn-primary">登录以后才可以发布留言</span>
                            </c:if>
                            <c:if test="${sessionScope.depart==22}">
                                <button class="layui-btn layui-btn-fluid layui-btn-danger">点我发布留言内容</button>
                            </c:if>
                        </form>



                    <div style="margin-top: 30px;">
                        <div class="site-title"
                             style="text-align: center;font-size: 20px;border-left:0px;border-right:0px;border-bottom:0px;   ">
                            <fieldset>
                                    <% while(rs.next()){

                                        //为列表参数初始化

                                        Integer id = rs.getInt("id");
                                        String username = rs.getString("username");
                                        String createtime = rs.getString("createtime");
                                        String message = rs.getString("message");
                                        String deleteUri =  "/view/back/liuyan/doLiuyyanExcute.jsp?state=3&id="+id;
                                        Integer userId = rs.getInt("userid");
                                        String avatar = rs.getString("avatar");


                                    %>


                                    <div class='comment'>
                                        <img src='<%=avatar%>' alt='head pic'/>
                                        <a class="name" href=""><%=username%></a>
                                        <p><%=message%></p>
                                        <span><%=createtime%></span>
<%--                                        <a class='up dianzan' href="javascript:void(0);" dataid="${v.id}"><i--%>
<%--                                                class="layui-icon layui-icon-praise"></i> <b--%>
<%--                                                style="font-size: 18px;color: green;">${v.likenum}</b></a>--%>
                                    </div>
                                    <%}%>





                            </fieldset>
                        </div>
                    </div>
                </div>

            </div>





        </div>

        <div class="layui-col-md12 layui-col-sm12">
            <div id="demo0"></div>
        </div>





    </div>

</div>

<style>
    .comment {
        margin-top: 4%;
        margin-left: 14%;
        padding: 2%;
        width: 68%;
        background-color: #ececec;
        border: 1px dashed #888;
        border-radius: 1em;
        position: relative;
        display: block;
        text-align: left;
    }

    .comment:hover img {
        border-radius: 1em;
        border: 2px solid #888;
    }

    .comment:hover {
        background-color: #eee;
    }

    .comment img {
        position: absolute;
        top: -1%;
        left: -10%;
        border-radius: 2em;
        border: 2px solid #888;
        width: 60px;
        height: 60px;
    }

    .comment p {
        text-indent: 2em;
        margin-top: 0.4%;
    }

    .comment span {
        position: absolute;
        top: 10%;
        right: 4%;
        font-size: 0.9em;
        font-weight: bold;
        color: #444
    }

    .comment .name {
        color: black;
        font-weight: bold;
        text-decoration: none;
    }

    .comment .name:hover {
        text-decoration: underline;
    }

    .comment .up {
        color: #555;
        text-decoration: none;
        position: absolute;
        bottom: 4%;
        right: 8%;
    }

    .comment .up:hover {
        color: #000;
    }
</style>
<script>
    //注意：导航 依赖 element 模块，否则无法进行功能性操作
    layui.use('element', function () {
        var element = layui.element;

        //…
    });
</script>
</body>
</html>
